class MyQueue {
public:
    MyQueue() {}

    stack<int> s1;  // 队头
    stack<int> s2;  // 队尾

    void push(int x) {
        s2.push(x);  // 入队，队尾入栈
    }
    
    int pop() {
        int ret = peek();
        s1.pop();
        return ret;
    }
      
    int peek() {  //返回队列开头的元素  
        if(s1.empty()){  // s1为空将s2所有元素搬移到s1中
            while(!s2.empty()){
                s1.push(s2.top());
                s2.pop();
            }
        }
        return s1.top();
    }
    
    bool empty() {
        if(s1.empty() && s2.empty())
            return true;
        else
            return false;
    }
};

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue* obj = new MyQueue();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->peek();
 * bool param_4 = obj->empty();
 */